import 'package:rongcloud_im_wrapper_plugin/rongcloud_im_wrapper_plugin.dart';

class ZtIMessageModel {
  String? userId;
  String? content; //聊天内容
  RCIMIWMessageType? type; //聊天类型
  String? nickname;
  int? sentTime;
  String? sentDay;
  String? avatarUrl;
  String? conversationId; //会话ID
  String? translatedText;
  bool isTranslating = false;
  String? filename;
  int? duration;
  String? messageId;
  String? filePath; // waiting for uploading, need use local path to display
  RCIMIWSentStatus sentStatus = RCIMIWSentStatus.sending;
  ZtIMessageModel(
      {this.userId,
      this.content,
      this.type,
      this.messageId,
      this.filename,
      this.filePath,
      this.sentDay,
      this.duration,
      this.nickname,
      this.sentTime,
      this.avatarUrl,
      required this.sentStatus,
      this.conversationId,
      this.isTranslating = false,
      this.translatedText});

  ZtIMessageModel.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    content = json['content'];
    isTranslating = json['isTranslating'];
    type = json['type'];
    messageId = json['messageId'];
    duration = json['duration'];
    sentStatus = json['sentStatus'];
    sentDay = json['sentDay'];
    filename = json['filename'];
    nickname = json['nickname'];
    sentTime = json['sentTime'];
    avatarUrl = json['avatarUrl'];
    conversationId = json['conversationId'];
    filePath = json['filePath'];
    translatedText = json['translatedText'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = userId;
    data['content'] = content;
    data['sentDay'] = sentDay;
    data['filePath'] = filePath;
    data['duration'] = duration;
    data['filename'] = filename;
    data['type'] = type;
    data['nickname'] = nickname;
    data['messageId'] = messageId;
    data['sentStatus'] = sentStatus;
    data['sentTime'] = sentTime;
    data['avatarUrl'] = avatarUrl;
    data['conversationId'] = conversationId;
    data['isTranslating'] = isTranslating;
    data['translatedText'] = translatedText;
    return data;
  }
}
